let timer;
let duration;

function start(time, callback) {
  duration = time
  timer = setInterval(function() {
    duration--;
    callback && callback.call(this, duration)
    if (duration == 0) {
      clearInterval(timer)
    }
  }, 1000)
}

function end() {
  clearInterval(timer)
}

export default {
  start,
  end
}